﻿#pragma once

#include <cassert>
#include <learn/geom/vec.h>
#include <learn/mesh/mesh3d.h>

namespace xi
{

namespace alg
{

using namespace xi::geom;
using namespace xi::mesh;

struct EXT_SYMBOL Alg_Delaunay
{
  public:
    struct Triangle
    {
        int i, j, k;

        int operator[](int w) const
        {
            switch (w)
            {
            case 0:
                return i;
            case 1:
                return j;
            case 2:
                return k;
            }
            // 立即报错
            assert(0);
            return 0;
        }

        int &operator[](int w)
        {
            switch (w)
            {
            case 0:
                return i;
            case 1:
                return j;
            case 2:
                return k;
            }
            // 立即报错
            assert(0);
            return i;
        }
    };

    /**
     * @brief
     *
     * @param[in] points
     * @return std::shared_ptr<Mesh3D<3>>
     */
    virtual std::shared_ptr<Mesh3D<3>> generate(std::vector<Vec3f> &&points) = 0;
};

struct EXT_SYMBOL Alg_Lawson_Delaunay : public Alg_Delaunay
{
  public:
    /**
     * @brief
     *
     * @param[in] points
     * @return std::shared_ptr<Mesh3D<3>>
     */
    std::shared_ptr<Mesh3D<3>> generate(std::vector<Vec3f> &&points) override;
};

} // namespace alg

} // namespace xi
